#include<iostream>
using namespace std;
#include<vector>
#include<queue>
class Solution {
public:
    class cmp {
    public:
        bool operator()(pair<int, int>& a1, pair<int, int>& a2) {
            return a1.first > a2.first || (a1.first == a2.first && a1.second > a2.second);
        }
    };
    vector<int> getFinalState(vector<int>& nums, int k, int multiplier) {
        priority_queue<pair<int, int>, vector<pair<int, int>>, cmp> que;
        for (int i = 0; i < nums.size(); ++i)
            que.push({ nums[i],i });
        while (k--) {
            pair<int, int> now = que.top();
            que.pop();
            nums[now.second] *= multiplier;
            now.first = nums[now.second];
            que.push(now);
        }
        return nums;
    }
};
int main() {
    vector<int> nums{ 1,3,5 };
    Solution().getFinalState(nums, 5, 3);
}